using UnityEngine;
using System.Collections;

public class killEnemy : MonoBehaviour {
	
	public GameObject me;
	
	public int lifeEnemy = 2;
	public colidir_inimigo x;
	public Rigidbody colidir;
	
	public bool vivo = true ;
	
	int puta = 0;
	
	telaDerrota td = new telaDerrota();
	
	// Use this for initialization
	void Start () {
	
		x = new colidir_inimigo();
		colidir = new Rigidbody();
		
		
	}
	
	// Update is called once per frame
	
	void Update()
	{
		
		
		if(lifeEnemy <= 0)
		{
			td.InimigosMortos++;
			Debug.Log("aaeaeae ");
			Destroy(me.gameObject);

		}
		
	}
	
	void OnTriggerEnter(Collider collider)
	{
		
		if(collider.gameObject.tag == "bala")
		{
			lifeEnemy = lifeEnemy - x.bulletPower;
			
			Destroy(collider.gameObject); //DESTROY A BALA QND COLIDE COM O INIMIGO.
			
		//	Debug.Log(lifeEnemy);
			
			
			/*if(lifeEnemy <= 0)
			{
				td.InimigosMortos++;
				Destroy(me.gameObject);					
			}*/		
		
			
			
		}
		if(collider.gameObject.tag == "player")
		{
			//fazer com q o inimigo colida
			
		collider.isTrigger = false;
						
		}
		
	}
	
}
